package com.rule.front.api.drools;

import com.rule.drools.entity.ActionParamInfoEntity;
import com.rule.drools.service.ActionParamInfoService;
import com.rule.core.utils.PageUtils;
import com.rule.core.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 动作参数信息表
 *
 * @author gz
 * @email 360568523@qq.com
 * @date 2019-05-25 14:54:38
 */
@RestController
@RequestMapping("rules/actionparaminfo")
public class ActionParamInfoController {
    @Autowired
    private ActionParamInfoService actionParamInfoService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public Result list(@RequestParam Map<String, Object> params){
        PageUtils page = actionParamInfoService.queryPage(params);

        return Result.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{actionParamId}")
    public Result info(@PathVariable("actionParamId") Long actionParamId){
		ActionParamInfoEntity actionParamInfo = actionParamInfoService.getById(actionParamId);

        return Result.ok().put("actionParamInfo", actionParamInfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public Result save(@RequestBody ActionParamInfoEntity actionParamInfo){
		actionParamInfoService.save(actionParamInfo);

        return Result.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public Result update(@RequestBody ActionParamInfoEntity actionParamInfo){
		actionParamInfoService.updateById(actionParamInfo);

        return Result.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public Result delete(@RequestBody Long[] actionParamIds){
		actionParamInfoService.removeByIds(Arrays.asList(actionParamIds));

        return Result.ok();
    }

}
